<template>
  <div id="recruitlist">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/recruit/unit/projectList' }">公开招聘</el-breadcrumb-item>
      <el-breadcrumb-item>历年招聘人员留存情况</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxs">
    <!--工具条-->
        <el-form :inline="true" :model="filters">
          <div>
            <el-form-item style="float:left" label="年度">
              <el-select v-model="filters.theYear">
                <el-option :value="null" label="全部" />
                <el-option v-for="(item,index) in yearList" :key="'year'+index" :value="item" :label="item" />
              </el-select>
            </el-form-item>
            <el-form-item label="单位名称">
              <el-input v-model="filters.unitName" placeholder=""></el-input>
            </el-form-item>
            <el-form-item label="姓名">
              <el-input v-model="filters.realName" placeholder=""></el-input>
            </el-form-item>
            <el-form-item label="身份证号">
              <el-input v-model="filters.idCardNo" placeholder=""></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="searchList" icon="el-icon-search">查询</el-button>
            </el-form-item>
            <div style="float:right">
              <el-form-item>
                <el-popconfirm title="确定批量删除所选信息吗？" @onConfirm="handleDelAll()" @confirm="handleDelAll()" style="float:right;margin-left:10px">
                  <el-button slot="reference" type="danger" class="filter-item">批量删除</el-button>
                </el-popconfirm>
                <el-upload style="margin:0;float:right;margin-left:10px" class="upload-demo" :before-upload="beforeAvatarUpload" :on-success="getImportList" :on-error="uploadError" name="file" :show-file-list="false"
                  :action="this.$http.defaults.baseURL + this.$http.defaults.recruitAPI + 'api/recruitBusCandidateRegistration/importFile'" with-credentials accept="vnd.openxmlformats-officedocument.spreadsheetml.sheet">
                  <el-button icon="el-icon-upload2" type="success" :loading="saveloading">批量导入</el-button>
                </el-upload>
                <el-button icon="el-icon-download" type="primary" style="float:right;margin-left:10px" @click="downloadTemplate()">下载模板</el-button>
                <el-button icon="el-icon-plus" type="success" @click="handleAdd">新增</el-button>
              </el-form-item>
            </div>
          </div>
        </el-form>
    </section>
    <section class="wboxd" style="margin-top:10px">
      <!--列表-->
      <el-dialog :title="dialogTitle" :visible.sync="editFormVisible" width="98%" top="20px">
        <el-form :model="editForm" label-width="200px" ref="editForm" :inline="true" style="padding:10px 0 0;clear:both" :rules="editFormRules">
          <table cellspacing="0" cellpadding="0" class="mytable">
            <tr>
              <th style="width:120px; vertical-align: middle;">年度</th>
              <td style="vertical-align: middle; width: 230px;">
                <el-form-item prop="theYear">
                  <el-select v-model="editForm.theYear">
                    <el-option v-for="(item,index) in yearList" :key="'year'+index" :value="item" :label="item" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">接收单位</th>
              <td style="vertical-align: middle;" :colspan="3">
                <el-form-item prop="unitName">
                  <el-input v-model="editForm.unitName" style="width:500px"></el-input>
                </el-form-item>
              </td>
              <!-- <th style="width:120px; vertical-align: middle;" v-if="type===3">来源</th>
              <td style="vertical-align: middle;" v-if="type===3">
                <el-form-item prop="theType">
                  <el-select v-model="editForm.theType" style="width:150px">
                    <el-option v-for="(item,index) in typeList" :key="'type_'+index" :value="item.value" :label="item.label" />
                  </el-select>
                </el-form-item>
              </td> -->
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;" v-if="unitBeijing===3">单位类型</th>
              <td style="vertical-align: middle;" v-if="unitBeijing===3" :colspan="editForm.unitBeijing===1?0:3">
                <el-form-item prop="unitBeijing" style="">
                  <el-radio-group v-model="editForm.unitBeijing">
                    <el-radio :label="1">在京单位</el-radio>
                    <el-radio :label="2">京外单位</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;" v-if="unitBeijing===1||editForm.unitBeijing===1">生源类型</th>
              <td style="vertical-align: middle; width: 230px;" v-if="unitBeijing===1||editForm.unitBeijing===1">
                <el-form-item prop="inBeijing">
                  <el-radio-group v-model="editForm.inBeijing">
                    <el-radio :label="1">京内生源</el-radio>
                    <el-radio :label="2">京外生源</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">生源地</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="place">
                  <el-select v-model="editForm.place" style="width:150px">
                    <el-option v-for="(item,index) in provinceOptions" :key="'place_'+index" :value="item.value" :label="item.label" />
                  </el-select>
                  <span v-if="isShow" style="color:red; font-size: 14px; font-weight:bolder; margin-left: 2px;">生源地和生源类型不一致</span>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">招聘方式</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="recruitmentMethod">
                  <el-select v-model="editForm.recruitmentMethod" style="width:150px">
                    <el-option v-for="(item,index) in recruitmentMethodList" :key="'recruitmentMethod_'+index" :value="item.value" :label="item.label" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">拟聘部门</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="department">
                  <el-input v-model="editForm.department" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">岗位</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="post">
                  <el-input v-model="editForm.post" style="width:200px"></el-input>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">姓名</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="realName">
                  <el-input v-model="editForm.realName" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">性别</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="sex">
                  <el-select v-model="editForm.sex" style="width:150px">
                    <el-option v-for="(item,index) in sexList" :key="'sex_'+index" :value="item.value" :label="item.label" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">民族</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="nation">
                  <el-select v-model="editForm.nation" style="width:150px">
                    <el-option v-for="(item,index) in nationList" :key="'nation_'+index" :value="item" :label="item" />
                  </el-select>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">身份证号</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="idCardNo">
                  <el-input v-model="editForm.idCardNo" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">婚姻状况</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="maritalStatus">
                  <el-select v-model="editForm.maritalStatus" style="width:150px">
                    <el-option v-for="(item,index) in maritalStatusList" :key="'maritalStatus_'+index" :value="item" :label="item" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">毕业生手机号码</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="phone">
                  <el-input v-model="editForm.phone" style="width:200px"></el-input>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">学历</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="education">
                  <el-select v-model="editForm.education" style="width:150px">
                    <el-option v-for="(item,index) in educationList" :key="'education_'+index" :value="item" :label="item" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">学位</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="degree">
                  <el-select v-model="editForm.degree" style="width:150px">
                    <el-option v-for="(item,index) in degreeList" :key="'degree_'+index" :value="item" :label="item" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">籍贯</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="nativePlace">
                  <el-input v-model="editForm.nativePlace" style="width:200px"></el-input>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;" rowspan="3">毕业院校</th>
              <th style="width:120px; vertical-align: middle;">名称</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="school">
                  <el-input v-model="editForm.school" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;" rowspan="3">专业</th>
              <th style="width:120px; vertical-align: middle;">专业大类</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="majorClass1">
                  <el-input v-model="editForm.majorClass1" style="width:200px"></el-input>
                  <!-- <el-cascader v-model="editForm.majorClass" :options="options" /> -->
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">所在地</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="schoolLocation">
                  <el-input v-model="editForm.schoolLocation" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">专业中类</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="majorClass2">
                  <el-input v-model="editForm.majorClass2" style="width:200px"></el-input>
                  <!-- <el-cascader v-model="editForm.majorClass" :options="options" /> -->
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">是否留学生</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="internationalStudent">
                  <el-select v-model="editForm.internationalStudent">
                    <el-option :value="1" label="是" />
                    <el-option :value="0" label="否" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">专业名称</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="major">
                  <el-input v-model="editForm.major" style="width:200px"></el-input>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">是否留存</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="inPost">
                  <el-select v-model="editForm.inPost">
                    <el-option :value="1" label="是" />
                    <el-option :value="0" label="否" />
                  </el-select>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;" v-if="!editForm.inPost">离职时间</th>
              <td style="vertical-align: middle;" v-if="!editForm.inPost">
                <el-form-item prop="resignationDate">
                  <el-date-picker
                    v-model="editForm.resignationDate"
                    value-format="yyyy-MM-dd"
                    type="date"
                    placeholder="选择日期">
                  </el-date-picker>
                  <span v-if="resignationText&&editForm.resignationDate" style="color:red; font-size: 14px; font-weight:bolder; margin-left: 2px;">{{ resignationText }}</span>
                </el-form-item>
              </td>
              <!-- <th style="width:120px; vertical-align: middle;">是否实际接收落户</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="isSettleDown">
                  <el-select v-model="editForm.isSettleDown">
                    <el-option :value="1" label="是" />
                    <el-option :value="0" label="否" />
                  </el-select>
                </el-form-item>
              </td> -->
              <th style="width:130px; vertical-align: middle;">备注</th>
              <td style="vertical-align: middle;" :colspan="editForm.inPost?3:1">
                <el-form-item prop="remarks">
                  <el-input v-model="editForm.remarks" style="width:400px"></el-input>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th style="width:120px; vertical-align: middle;">填表人</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="inputer">
                  <el-input v-model="editForm.inputer" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">手机</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="inputerPhone">
                  <el-input v-model="editForm.inputerPhone" style="width:200px"></el-input>
                </el-form-item>
              </td>
              <th style="width:120px; vertical-align: middle;">填表日期</th>
              <td style="vertical-align: middle;">
                <el-form-item prop="inputDate">
                  <el-date-picker
                    v-model="editForm.inputDate"
                    value-format="yyyy-MM-dd"
                    type="date"
                    placeholder="选择日期">
                  </el-date-picker>
                  <span v-if="inputText" style="color:red; font-size: 14px; font-weight:bolder; margin-left: 2px;">{{ inputText }}</span>
                </el-form-item>
              </td>
            </tr>
          </table>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click.native="editFormSubmit" :loading="editLoading">提交</el-button>
          <el-button @click.native="editFormVisible = false">取消</el-button>
        </div>
      </el-dialog>
      <el-table :data="selectionlist" highlight-current-row v-loading="listLoading" style="width: 100%;border-top:1px solid #9CA3B3" :height="tableHeight" border id="selectionindexlist" row-key="personId"
        default-expand-all
        @selection-change="handleSelectionChange"
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column width="50px" align="center" type="selection" />
        <el-table-column label="年度" align="center" prop="theYear" width="60" />
        <el-table-column prop="unitName" label="单位名称" min-width="150">
        </el-table-column>
        <el-table-column prop="post" label="岗位名称" width="120" align="center">
        </el-table-column>
        <el-table-column prop="realName" label="姓名" width="80" align="center">
        </el-table-column>
        <el-table-column prop="idCardNo" label="身份证号" width="200" align="center">
        </el-table-column>
        <el-table-column prop="school" label="毕业院校" width="150" align="center">
        </el-table-column>
        <el-table-column prop="major" label="专业" width="150" align="center">
        </el-table-column>
        <el-table-column prop="education" label="学历" width="110" align="center">
        </el-table-column>
        <el-table-column prop="recruitmentMethod" label="招聘方式" width="90" align="center">
          <template slot-scope="scope">
            {{scope.row.recruitmentMethod===1?'考试':'引进'}}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150">
          <template slot-scope="scope">
            <template>
              <el-dropdown split-button  @click="handleDetail(scope.row)" type="primary" :loading="btnLoading">
                修改
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item @click.native="handleDel(scope.row.id)" >删除</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination :total="totalnum" :page-size="pageSize" @current-change="handleCurrentChange" :current-page="pageNum" @size-change="handleSizeChange" :page-sizes="[20, 30, 50, 100]" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  watch: {
    editForm: {
      handler (newVal) {
        if (newVal.place === '') {
          this.isShow = false
          return
        }
        if (newVal.unitBeijing === 2) {
          this.isShow = false
          return
        }
        if (newVal.inBeijing === 1) {
          newVal.place === '北京市' ? this.isShow = false : this.isShow = true
        } else if (newVal.inBeijing === 2) {
          newVal.place === '北京市' ? this.isShow = true : this.isShow = false
        } else {
          this.isShow = false
        }
      },
      deep: true
    }
  },
  data () {
    return {
      saveloading: false,
      unitBeijing: null,
      sexList: [{label: '男', value: 1}, {label: '女', value: 2}],
      nationList: [
        '汉族',
        '蒙古族',
        '回族',
        '藏族',
        '维吾尔族',
        '苗族',
        '彝族',
        '壮族',
        '布依族',
        '朝鲜族',
        '满族',
        '侗族',
        '瑶族',
        '白族',
        '土家族',
        '哈尼族',
        '哈萨克族',
        '傣族',
        '黎族',
        '傈僳族',
        '佤族',
        '畲族',
        '高山族',
        '拉祜族',
        '水族',
        '东乡族',
        '纳西族',
        '景颇族',
        '柯尔克孜族',
        '土族',
        '达斡尔族',
        '仫佬族',
        '羌族',
        '布朗族',
        '撒拉族',
        '毛南族',
        '仡佬族',
        '锡伯族',
        '阿昌族',
        '普米族',
        '塔吉克族',
        '怒族',
        '乌孜别克族',
        '俄罗斯族',
        '鄂温克族',
        '德昂族',
        '保安族',
        '裕固族',
        '京族',
        '塔塔尔族',
        '独龙族',
        '鄂伦春族',
        '赫哲族',
        '门巴族',
        '珞巴族',
        '基诺族'
      ],
      maritalStatusList: ['未婚', '已婚', '离婚', '丧偶'],
      degreeList: ['博士', '硕士', '学士', '其他'],
      educationList: ['大专', '本科生', '硕士研究生', '博士研究生', '其他'],
      recruitmentMethodList: [{label: '考试', value: 1}, {label: '引进', value: 2}],
      yearList: [],
      theYear: 2023,
      yearLoading: false,
      btnLoading: false,
      editFormVisible: false,
      editLoading: false,
      listLoading: false,
      editForm: {
        id: null,
        theYear: '',
        unitName: '',
        theType: '',
        department: '',
        post: '',
        realName: '',
        idCardNo: '',
        sex: '',
        nation: '',
        maritalStatus: '',
        phone: '',
        school: '',
        schoolLocation: '',
        place: '',
        major: '',
        majorClass1: '',
        majorClass2: '',
        education: '',
        degree: '', // 表单缺
        recruitmentMethod: '', // 表单缺
        unitBeijing: '', // 表单缺
        inBeijing: '', // 表单缺
        inputer: '',
        inputerPhone: '',
        inputDate: '',
        originalUnit: '',
        inPost: null,
        resignationDate: '',
        isSettleDown: 1,
        internationalStudent: null,
        remarks: '',
        nativePlace: ''
      },
      editFormRules: {
        theYear: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        unitName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        theType: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        department: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        post: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        realName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        idCardNo: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        sex: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        nation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        maritalStatus: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        school: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        schoolLocation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        place: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        major: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        majorClass1: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        education: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        degree: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        recruitmentMethod: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        unitBeijing: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inBeijing: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputer: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputerPhone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputDate: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        originalUnit: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inPost: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        resignationDate: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        isSettleDown: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        internationalStudent: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        nativePlace: [
          { required: true, message: '必填', trigger: 'blur' }
        ]
      },
      dialogTitle: '新增',
      timestamp: '',
      changeType: '',
      substep: '',
      steppersonId: '',
      personId: '',
      jdcchuzhang: '',
      chuzhangs: [],
      tasknum: '',
      filters: {
        idCardNo: '',
        realName: '',
        unitName: '',
        year: null
      },
      selectionlist: [],
      totalnum: 0,
      pageNum: 1,
      pageSize: 30,
      changeSizeFlag: false,
      unitName: '',
      necessaryItems: [],
      mangeDep: [],
      tableHeight: 100,
      userRoles: '',
      jdcuserlist: [],
      jdcsetting: [],
      jdc1: '',
      jdc2: '',
      jdc3: '',
      jdc4: '',
      provinceOptions: [
        {label: '北京市', value: '北京市'},
        {label: '天津市', value: '天津市'},
        {label: '河北省', value: '河北省'},
        {label: '山西省', value: '山西省'},
        {label: '内蒙古自治区', value: '内蒙古自治区'},
        {label: '辽宁省', value: '辽宁省'},
        {label: '吉林省', value: '吉林省'},
        {label: '黑龙江省', value: '黑龙江省'},
        {label: '上海市', value: '上海市'},
        {label: '江苏省', value: '江苏省'},
        {label: '浙江省', value: '浙江省'},
        {label: '安徽省', value: '安徽省'},
        {label: '福建省', value: '福建省'},
        {label: '江西省', value: '江西省'},
        {label: '山东省', value: '山东省'},
        {label: '河南省', value: '河南省'},
        {label: '湖北省', value: '湖北省'},
        {label: '湖南省', value: '湖南省'},
        {label: '广东省', value: '广东省'},
        {label: '广西壮族自治区', value: '广西壮族自治区'},
        {label: '海南省', value: '海南省'},
        {label: '重庆市', value: '重庆市'},
        {label: '四川省', value: '四川省'},
        {label: '贵州省', value: '贵州省'},
        {label: '云南省', value: '云南省'},
        {label: '西藏自治区', value: '西藏自治区'},
        {label: '陕西省', value: '陕西省'},
        {label: '甘肃省', value: '甘肃省'},
        {label: '青海省', value: '青海省'},
        {label: '宁夏回族自治区', value: '宁夏回族自治区'},
        {label: '新疆维吾尔自治区', value: '新疆维吾尔自治区'},
        {label: '香港特别行政区', value: '香港特别行政区'},
        {label: '澳门特别行政区', value: '澳门特别行政区'},
        {label: '台湾省', value: '台湾省'}
      ],
      isShow: false,
      resignationText: '',
      inputText: '',
      multipleSelection: []
    }
  },
  methods: {
    uploadError (err) {
      this.saveloading = false
      console.log(err)
      this.$message({
        message: '上传失败:' + err,
        type: 'error'
      })
    },
    getImportList (res) {
      this.saveloading = false
      if (res.success) {
        if (res.result && res.result.length > 0) {
          this.errorList = res.result
          this.errorVisible = true
        } else {
          this.$message({
            message: `成功导入${res.result}条数据！`,
            type: 'success'
          })
          this.getList()
        }
      } else {
        this.$message({
          message: '导入失败:' + res.message,
          type: 'error'
        })
      }
    },
    beforeAvatarUpload (file) {
      console.log('文件类型')
      console.log(file.name)
      const isFormat = file.name.indexOf('.xlsx') > 0
      // const isLt5M = file.size / 1024 / 1024 < 500
      if (!isFormat) {
        this.$message.error('上传文件只能是 .xlsx 格式!')
        return false
      }
      return isFormat
    },
    downloadTemplate () {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.recruitAPI + 'api/recruitBusCandidateRegistration/getImportTemplate')
    },
    getYear () {
      this.yearLoading = true
      this.$http
        .get(this.$http.defaults.recruitAPI + `api/recruitBusAuth/currentYear`)
        .then(response => {
          this.yearLoading = false
          this.theYear = response.data.result
          this.yearList = []
          for (let i = this.theYear; i > this.theYear - 5; i--) {
            console.log(i)
            this.yearList.push(i)
          }
        })
        .catch(error => {
          this.$message({
            message: '获取失败:' + error,
            type: 'error'
          })
          this.yearLoading = false
        })
    },
    searchList () {
      this.pageNum = 1
      this.getList()
    },
    ftypename (type) {
      switch (type) {
        case 1:
          return '应届毕业生招聘'
        case 2:
          return '在职人员招聘'
        case 3:
          return '其他招聘'
      }
    },
    doit (id, step) {
      this.$router.push({name: 'recruitUnitDetail', query: {step: step, unitBatchId: id}})
    },
    audit (id) {
      this.$router.push({name: 'recruitUnitAudit', query: {id: id}})
    },
    formatDate (date, flag) {
      if (/^\d{4}(\d{2}\d{2}|-\d{2}-\d{2})?$/g.test(date)) {
        if (date && date.length === 8) {
          const dateArr = date.split('')
          dateArr.splice(4, 0, '-')
          dateArr.splice(7, 0, '-')
          return dateArr.join('')
        } else if (date && date.length === 10) {
          return date
        }
      } else {
        if (flag === 'input') {
          this.inputText = `当前值${date}格式有误，请重新选择`
        } else if (flag === 'resignation') {
          this.resignationText = `当前值${date}格式有误，请重新选择`
        }
        return ''
      }
    },
    handleDetail (obj) {
      this.dialogTitle = '修改'
      this.inputText = ''
      this.resignationText = ''
      this.editForm.id = obj.id
      this.editForm.unitName = obj.unitName
      this.editForm.theYear = obj.theYear
      this.editForm.theType = obj.theType
      this.editForm.department = obj.department
      this.editForm.post = obj.post
      this.editForm.realName = obj.realName
      this.editForm.idCardNo = obj.idCardNo
      this.editForm.sex = obj.sex
      this.editForm.nation = obj.nation
      this.editForm.maritalStatus = obj.maritalStatus
      this.editForm.phone = obj.phone
      this.editForm.school = obj.school
      this.editForm.schoolLocation = obj.schoolLocation
      this.editForm.place = obj.place
      this.editForm.major = obj.major
      this.editForm.majorClass1 = obj.majorClass1
      this.editForm.majorClass2 = obj.majorClass2
      this.editForm.education = obj.education
      this.editForm.degree = obj.degree
      this.editForm.recruitmentMethod = obj.recruitmentMethod
      this.editForm.inputer = obj.inputer
      this.editForm.inputerPhone = obj.inputerPhone
      this.editForm.unitBeijing = obj.unitBeijing
      this.editForm.inBeijing = obj.inBeijing
      this.editForm.inputDate = this.formatDate(obj.inputDate, 'input')
      this.editForm.originalUnit = obj.originalUnit
      this.editForm.inPost = obj.inPost
      this.editForm.resignationDate = this.formatDate(obj.resignationDate, 'resignation')
      this.editForm.internationalStudent = obj.internationalStudent
      this.editForm.isSettleDown = obj.isSettleDown
      this.editForm.remarks = obj.remarks
      this.editForm.nativePlace = obj.nativePlace
      this.editFormVisible = true
    },
    handleAdd () {
      this.dialogTitle = '新增'
      this.editForm.id = null
      this.editForm.theYear = ''
      this.editForm.unitName = ''
      this.editForm.department = ''
      this.editForm.post = ''
      this.editForm.realName = ''
      this.editForm.idCardNo = ''
      this.editForm.sex = ''
      this.editForm.nation = ''
      this.editForm.maritalStatus = ''
      this.editForm.phone = ''
      this.editForm.school = ''
      this.editForm.schoolLocation = ''
      this.editForm.place = ''
      this.editForm.major = ''
      this.editForm.majorClass1 = ''
      this.editForm.majorClass2 = ''
      this.editForm.education = ''
      this.editForm.degree = ''
      this.editForm.recruitmentMethod = ''
      this.editForm.inputer = ''
      this.editForm.inputerPhone = ''
      this.editForm.unitBeijing = ''
      this.editForm.inBeijing = ''
      this.editForm.inputDate = ''
      this.editForm.originalUnit = ''
      this.editForm.inPost = null
      this.editForm.resignationDate = ''
      this.editForm.internationalStudent = null
      this.editForm.isSettleDown = ''
      this.editForm.remarks = ''
      this.editForm.nativePlace = ''
      this.editFormVisible = true
    },
    // 批量删除
    handleSelectionChange (val) {
      this.multipleSelection = val
    },
    handleDelAll () {
      const ids = this.multipleSelection.map(item => item.id)
      if (ids.length > 0) {
        this.listLoading = true
        this.$http
          .post(this.$http.defaults.recruitAPI + 'api/recruitBusCandidateRegistration/remove', { ids: ids })
          .then(response => {
            if (response.data.success === true) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.getList()
            } else {
              this.listLoading = false
              console.log('删除失败:' + response.data.message)
              this.$message({
                message: '删除失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            this.listLoading = false
            console.log(error)
          })
      } else {
        this.$message({
          message: '请至少选择一条信息',
          type: 'danger'
        })
      }
    },
    handleDel (id) {
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'warning'
      }).then(() => {
        let para = {ids: [id]}
        this.listLoading = true
        this.$http.post(this.$http.defaults.recruitAPI + 'api/recruitBusCandidateRegistration/remove', para)
          .then(response => {
            if (response.data.success === true) {
              this.listLoading = false
              this.$message({
                message: '删除成功',
                type: 'success'
              })
            } else {
              this.listLoading = false
              console.log('删除失败:' + response.data.message)
              this.$message({
                message: '删除失败:' + response.data.message,
                type: 'error'
              })
            }
            this.getList()
          })
          .catch(error => {
            this.btnLoading = false
            console.log(error)
            this.$message({
              message: '删除失败:' + error,
              type: 'error'
            })
          })
      })
    },
    editFormSubmit () {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.editLoading = true
          let para = {
            id: this.editForm.id,
            theYear: this.editForm.theYear,
            unitName: this.editForm.unitName,
            theType: this.editForm.theType,
            department: this.editForm.department,
            post: this.editForm.post,
            realName: this.editForm.realName,
            idCardNo: this.editForm.idCardNo,
            sex: this.editForm.sex,
            nation: this.editForm.nation,
            maritalStatus: this.editForm.maritalStatus,
            phone: this.editForm.phone,
            school: this.editForm.school,
            schoolLocation: this.editForm.schoolLocation,
            place: this.editForm.place,
            major: this.editForm.major,
            majorClass1: this.editForm.majorClass1,
            majorClass2: this.editForm.majorClass2,
            education: this.editForm.education,
            degree: this.editForm.degree,
            recruitmentMethod: this.editForm.recruitmentMethod,
            inputer: this.editForm.inputer,
            inputerPhone: this.editForm.inputerPhone,
            unitBeijing: this.unitBeijing === 3 ? this.editForm.unitBeijing : this.unitBeijing,
            inBeijing: this.editForm.inBeijing,
            inputDate: this.editForm.inputDate,
            originalUnit: this.editForm.originalUnit,
            inPost: this.editForm.inPost,
            resignationDate: this.editForm.inPost ? '' : this.editForm.resignationDate,
            internationalStudent: this.editForm.internationalStudent,
            isSettleDown: 1,
            remarks: this.editForm.remarks,
            postDockingId: 0,
            state: 2,
            noTestMajorFlag: true,
            nativePlace: this.editForm.nativePlace
          }
          if (this.isShow) {
            this.$confirm('生源地和生源类型不一致，是否确认保存？', '提示', {
              type: 'warning'
            }).then(() => {
              this.editFormPost(para)
            }).catch(() => {
              this.editLoading = false
            })
          } else {
            this.editFormPost(para)
          }
        }
      })
    },
    editFormPost (para) {
      this.$http.post(this.$http.defaults.recruitAPI + `api/recruitBusCandidateRegistration/save`, para).then(response => {
        console.log(response.data.success)
        if (response.data.success === true) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.editFormVisible = false
          this.editLoading = false
          this.getList()
        } else {
          console.log('提交失败:' + response.data.message)
          this.$message({
            message: '提交失败:' + response.data.message,
            type: 'error'
          })
          this.editLoading = false
        }
      }).catch(error => {
        console.log(error)
        this.$message({
          message: '提交失败:' + error,
          type: 'error'
        })
        this.editLoading = false
      })
    },
    handleSizeChange (val) {
      console.log('handleSizeChange', val)
      this.changeSizeFlag = true
      this.pageNum = 1
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange (val) {
      console.log('handleCurrentChange', val)
      if (this.changeSizeFlag === false) {
        this.pageNum = val
        this.getList()
      }
    },
    getList () {
      let para = {
        theYear: this.filters.theYear,
        idCardNo: this.filters.idCardNo,
        realName: this.filters.realName,
        unitName: this.filters.unitName,
        state: 2,
        isSettleDown: 1, // 京内单位京外生源新增时默认落户状态为0，落户后才更新为1，其他人新增时直接落户状态就是1
        'pageNum': this.pageNum,
        'pageSize': this.pageSize
      }
      this.listLoading = true
      this.$http
        .post(this.$http.defaults.recruitAPI + `api/recruitBusCandidateRegistration/queryByPage`, para)
        .then(response => {
          this.listLoading = false
          this.selectionlist = response.data.result.records
          this.totalnum = response.data.result.total
          this.changeSizeFlag = false
          if (this.selectionlist.length === 0 && this.pageNum > 1) {
            this.pageNum--
            this.getList()
          }
        })
        .catch(error => {
          this.$message({
            message: '获取失败:' + error,
            type: 'error'
          })
          this.listLoading = false
        })
    },
    getUnitBeijing () {
      this.$http
        .get(this.$http.defaults.recruitAPI + `api/recruitBusUnit/getUnitBeijing`)
        .then(response => {
          this.unitBeijing = response.data.result
        })
        .catch(error => {
          this.$message({
            message: '获取失败:' + error,
            type: 'error'
          })
        })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
      // obj.tableHeight = clientHeight - 292
        obj.tableHeight = clientHeight - 262
      })
    }
  },
  mounted () {
    this.getUnitBeijing()
    this.getYear()
    this.getList()
    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
.selectioncontent{
  border-bottom:1px solid #333;
  padding:5px !important;
}
  .pointtab .el-badge__content.is-fixed{
    right: -5px;
    top:18px;
  }
  .pointtab{
    padding-right:22px;
  }
  .pointRadio .el-badge__content.is-fixed{
    right: -5px;
    top:6px;
  }
  .pointRadio .el-radio-button__inner{
    height:40px;
    padding-left:15px;
    padding-right:42px;
  }
#recruitlist .el-table--border td, .el-table--border th, .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed{
  border-bottom:1px solid #95B8E7;
}
#recruitlist .el-table td, #recruitlist .el-table th.is-leaf{
  border-right:1px solid #95B8E7;
}
  .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    text-align: center;
    border-right: #95B8E7 solid 1px;
    border-bottom: #95B8E7 solid 1px;
    min-height: 30px;
    line-height:30px;
  }
  .wboxd .el-table td{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体',
  }
  .tableth{
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    height:33px;
  }
  #recruitlist .wboxs{
    height:45px;
    padding-top:10px;
  }
  #recruitlist .el-table__row{
    height: 50px;
  }
  #recruitlist #legent{
    float:right;
    margin-right: 20px;
  }
  #recruitlist #legent div{
    float:left;
    line-height: 42px;
    font-size:var(--size12);
  }
  #recruitlist #legent i{
    width: 30px;
    height: 30px;
    background-position: center center;
    background-repeat: no-repeat;
    float: left;
    display: block;
    margin:5px 0px 0 3px;
  }
  #recruitlist #selectionindexlist .cell i.custom{
    width: 30px;
    height: 30px;
    background-position: center center;
    background-repeat: no-repeat;
    float: center;
    display: block;
    margin:0 auto;
  }
  #recruitlist .el-step__title.is-finish {
    color: #409EFF;
  }
  #recruitlist .el-step__title {
    font-size:12px;
    line-height: 22px;
    padding-left: 8px;
  }
  #recruitlist .el-steps{
    margin:10px 0;
  }
  .el-tooltip__popper.is-dark{
    font-size:var(--size18) !important;
  }
  .el-tabs--card>.el-tabs__header {
    border-bottom: 1px solid #9CA3B3;
  }
  .el-tabs--card>.el-tabs__header .el-tabs__nav {
    border: 1px solid #9CA3B3;
    border-bottom: 0;
  }
  .el-tabs--card>.el-tabs__header .el-tabs__item {
    border-left: 1px solid #9CA3B3;
    /* background-color: #F0F0F0; */
  }
  .el-tabs__item.is-active {
    color: #0000FF !important;
    font-weight: bolder !important;
    /* background-color: #fff !important; */
    /* border-bottom: 2px solid #9CA3B3 !important; */
  }
</style>
<style scoped>
.mytable{
  border-top: 1px solid #74a6cc;
  border-left: 1px solid #74a6cc;
  margin:0 10px 10px;
  width: calc(100% - 20px);
}
.mytable th{
  padding: 10px;
  border-right: 1px solid #74a6cc;
  border-bottom: 1px solid #74a6cc;
  vertical-align: top;
  line-height: 150%;
  background: #FAFAFA;
  width:250px;
  text-align:right;
}
.mytable td{
  padding: 10px;
  border-right: 1px solid #74a6cc;
  border-bottom: 1px solid #74a6cc;
  vertical-align: top;
  line-height: 150%;
}
  .el-tooltip__popper{
    font-size:var(--size) !important;
  }
  h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>
